package com.csii.pos.cashdaily;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csii.adhoc.util.StringUtils;
import com.csii.pos.cashdaily.service.CashBulletinService;
import com.csii.pos.query.CashDaily;
import com.csii.result.APIResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: 头寸简报页面
 * @author: liuzhonghua
 * @create: 2021-7-20
 */
@Slf4j
@RequestMapping("cashdaily")
@RestController
public class CashBulletinController {
    @Resource
    private CashBulletinService cashBulletinService;

    /**
     * @description: 头寸简报分页查询
     * @param:  CashDaily
     * @return:  APIResult
     * @author liuzhonghua
     * @date:  2021.7.20
     */
    @RequestMapping("queryCashDaily")
    public APIResult<?> queryCashDaily(@RequestBody CashBulletin cashBulletin){
        List<CashBulletinVo> list = cashBulletinService.queryCashDaily(cashBulletin);
        return APIResult.successResult(list);

    }
    /**
     * @description:  输入框查询是提示接口
     * @param: cashBulletin
     * @return:  模糊查询list
     * @author liuzhonghua
     * @date:
     */
    @RequestMapping("queryHint")
    public APIResult<?> queryHint(@RequestBody CashDaily cashBulletin){
        QueryWrapper<CashDaily> queryWrapper = new QueryWrapper<>();
        queryWrapper.select("DISTINCT CSH_ITEM_CD");
        if (!StringUtils.isEmpty(cashBulletin.getCshItemCd())){
            queryWrapper.like("CSH_ITEM_CD",cashBulletin.getCshItemCd());
        }
        if (!StringUtils.isEmpty(cashBulletin.getCshRtpDt())){
            queryWrapper.eq("CSH_RTP_DT",cashBulletin.getCshRtpDt());
        }
        List<CashDaily> list = cashBulletinService.list(queryWrapper);
        return APIResult.successResult(list);
    }
}
